<style type="text/css">
#chapter_content {
	width: 400px;
}
</style>
<form id="create-chapter" method="post" action="<?php echo $this->createUrl('chapter/create',array('id'=>$lesson->lesson_id));?>">
	ชื่อ<br />
	<input type="text" name="createChapter[chapter_name]" /><br />
	เนื้อหา<br />
	<textarea id="chapter_content" name="createChapter[chapter_content]"></textarea><br />
	<input type="submit" value="ตกลง" />
</form>
<script type="text/javascript">
$(function(){
	$('#create-chapter').submit(function(event){
		event.preventDefault();
		var url = $(this).attr('action');
		var data = {};
		$(this).find('*[name]').each(function(){
			data[$(this).attr('name')] = $(this).val();
		});
	
		$.ajax(url,{
			'data' : data,
			'type' : 'post',
			'success' : function(data){
				if(data.success){
					window.location.href=window.location.href;
				}
				else {
					console.log(data);
				}
			},
			'dataType' : 'JSON'
		});
	});
});
</script>